package de.hsb.ai.agent.jcau;

import game.Link;
import game.Move;
import game.Node;
import game.Transport;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.TreeSet;

import de.hsb.ai.agent.AbstractDetective;
import de.hsb.ai.domain.MoveEvent;
import de.hsb.ai.util.map.ScotlandJadeMapHelper.ScotlandJadeVertex;
import de.hsb.ai.util.map.ScotlandJadeMapHelper.ScotlandJadeEdge;
/**
 * EstimatingDetectiveTac1 Estimates the possible Positions of Mr. X and moves
 * in direction of position, which is the closest.
 */
@SuppressWarnings("serial")
public class EstimatingDetectiveTac2 extends EstimatingDetective{

	
	public EstimatingDetectiveTac2() {
		super("estimatingTac2");
	}
	@Override
	protected Move getMove(List<Move> options) {
		if (lastKnownFugitivePosition != -1){	
			//initialize temporary distance and reset required values
			distanceToFugitive = Integer.MAX_VALUE;
			int distanceToFugitiveTmp = Integer.MAX_VALUE;
			debugEstimatedPosition = 0;
			Move moveTmp = null;
			
			for (ScotlandJadeVertex v : possibleNodes){	
				possibleNode = v.getIndex();
				
				
				
				
				//Reset "nextMove" to recognize in case of no move was found
				//Reset max Value for new searching
				searchDepth = Integer.MAX_VALUE;
				nextMove = null;
				
				
				
				//Start A* to find the shortest path to destination
				determineNextMove(currentPosition, 0);
				
				//Check which possible Node has the biggest distance to our detective					
				if(distanceToFugitiveTmp > distanceToFugitive){
					distanceToFugitiveTmp = distanceToFugitive;
					moveTmp = nextMove;
					debugEstimatedPosition = possibleNode;
				}
				
//				logger.debug(Integer.toString(nextMove.getNode()));
	
			}
			
			nextMove = moveTmp;
			logger.debug("Estimating Mr. X at: " + debugEstimatedPosition);
		
		}
	
		return super.getMove(options);
	}
	
	
	@Override
	protected void handleMove(MoveEvent m) {
		
		super.handleMove(m);
		
	}
}